function addEventList(
  obj: any,
  type: any,
  callback: any,
  useCapture: any = false
) {
  if (obj.eventList) {
    if (obj.eventList[type]) {
      obj.eventList[type].push({ callback: callback, useCapture: useCapture });
    } else {
      obj.eventList[type] = [{ callback: callback, useCapture: useCapture }];
    }
  } else {
    obj.eventList = {};
    obj.eventList[type] = [{ callback: callback, useCapture: useCapture }];
  }
}

function removeEventList(
  obj: any,
  type: any,
  callback: any,
  useCapture: any = false
) {
  var eventList = obj.eventList;
  if (eventList) {
    if (eventList[type]) {
      for (var i = 0; i < eventList[type].length; i++) {
        if (eventList[type][i].callback === callback) {
          eventList[type].splice(i, 1);
          if (eventList[type].length === 0) {
            delete eventList[type];
          }
          break;
        }
      }
    }
  }
}
export function addEvent(
  obj: any,
  type: any,
  callback: any,
  useCapture: any = false
) {
  obj.addEventListener(type, callback, useCapture);
  addEventList(obj, type, callback, useCapture);
}

export function removeEvent(
  obj: any,
  type: any,
  callback: any,
  useCapture: any = false
) {
  obj.removeEventListener(type, callback, useCapture);
  removeEventList(obj, type, callback, useCapture);
}
